﻿using Abp.AspNetCore;
using Abp.AspNetCore.Configuration;
using Abp.Configuration.Startup;
using Abp.Modules;
using Microsoft.Extensions.Configuration;
using Basefr.Modules;
using Abp.Reflection.Extensions;

namespace Paas.Svc.Host
{
    [DependsOn(
        typeof(AbpAspNetCoreModule),
        typeof(Basefr.Web.Module),
        typeof(Basefr.Logging.Module),
        typeof(Paas.App.Module))]
    public class Module : StartupModuleBase<Module>
    {
        private readonly IConfiguration _configuration;

        public Module(IConfiguration configuration)
        {
            _configuration = configuration;
        }

        public override void PreInitialize()
        {
            base.PreInitialize();

            Configuration.Modules.AbpAspNetCore().DefaultWrapResultAttribute.WrapOnSuccess = true;
            Configuration.Modules.AbpAspNetCore().DefaultWrapResultAttribute.WrapOnError = true;
            Configuration.Modules.AbpWebCommon().SendAllExceptionsToClients = true;

            //Configuration.Modules.AbpAspNetCore().CreateControllersForAppServices(typeof(Paas.App.Module).Assembly);
            Configuration.Modules.AbpAspNetCore()
                .CreateControllersForAppServices(
                    typeof(Paas.App.Module).GetAssembly()
                );
            Configuration.Modules.AbpAspNetCore()
                 .CreateControllersForAppServices(
                     typeof(Paas.App.Interface.Module).GetAssembly(), moduleName: "v1", useConventionalHttpVerbs: true
                 );
            //此种生成接口/api/services/v1/Role/Create，默认的是/api/services/app/Role/Create（此处接口都是举例）
        }
    }
}

